﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GBPVR.Public;

namespace GBPVRLibrary.ControlLibrary
{
    public class KeyMapper
    {
        public enum ControlKey
        {
            Unknown,
            DirectionUp, DirectionDown, DirectionLeft, DirectionRight,
            Back, Enter, PageUp, PageDown,
            NextView,
            Blue, Green, Red, Yellow
        }

        private static KeyCommandHelper KeyCommandHelper { get; set; }

        public static ControlKey GetControlKey(System.Windows.Forms.KeyEventArgs e)
        {
            if (KeyCommandHelper == null)
                KeyCommandHelper = new KeyCommandHelper("GBPVRLibrary.xml");
            string skey = KeyCommandHelper.KeyMapping(e);
            if (String.IsNullOrEmpty(skey))
                return ControlKey.Unknown;

            ControlKey? key = Enum.Parse(typeof(ControlKey), skey, true) as ControlKey?;
            if (key != null)
                return key.Value;
            return ControlKey.Unknown;
        }
    }
}
